/**
 * 获取鼠标位置
 */
export default function useMousePosition() {
  const x = ref(0)
  const y = ref(0)
  function update(e: MouseEvent) {
    x.value = e.pageX
    y.value = e.pageY
  }
  onMounted(() => {
    console.log('useMousePosition mounted')
    window.addEventListener('mousemove', update)
  })
  onUnmounted(() => {
    console.log('useMousePosition unMounted')
    window.removeEventListener('mousemove', update)
  })
  return {
    x,
    y
  }
}
